{% extends 'base.html' %}
{% block content %}

  <h2>Provas</h2>
    <h4>Bem vindo, <span id="username">{{ user }}!</span></h4>
    
  {% if user_exam_list %}
    <table class="table table-bordered table-striped">
      <thead>
        <tr>
          <th>Código</th>
          <th>Prova</th>
          <th>Data Limite</th>
          <th>Progresso</th>
          <th>Status</th>
          <th>Ação</th>
        </tr>
      </thead>
      <tbody>
        {% for exam in user_exam_list %}
        
          <tr>
            <td>{{ exam.id }}</td>
            <td>{{ exam.exam }}</td>
            <td {% if exam.has_expired and not exam.end_time %} style="color: red;" {% endif %}>{{ exam.expire_date|date:"d/m/Y à\s H:i" }}</td>
            <td>{{ exam.get_progress }}</td>
           	<td>{{ exam.get_status }}</td>
            <td>
              {% if not exam.has_expired %}
                {% if not exam.start_time %}
                  <a href="/prova/{{ exam.id }}/iniciar/" class="btn btn-small btn-success">Iniciar</a>
                {% elif exam.start_time and not exam.end_time %}
                  <a href="/prova/{{ exam.id }}/" class="btn btn-small btn-warning">Continuar</a>
                  {% if exam.get_progress == '100%' %}
                    <a href="/prova/{{ exam.id }}/enviar/" class="btn btn-small btn-primary">Enviar</a>
                  {% endif %}
                {% endif %}
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% else %}
	<p>Nenhuma prova cadastrada.</p>
  {% endif %}
  
  
<!-- TRECHO DE VISUALIZACAO DAS PROVAS PARA O ADMIN -->  
{% if user.username  == 'admin'	 %}
		<br/><h4><p>Provas Realizadas:</p></h4>
		
		
		<table class="table table-bordered table-striped">
		<thead>
        <tr>
          <th>Código</th>
          <th>Us&uacute;ario</th>
          <th>Prova</th>
          <th>Status</th>
          <th>Progresso</th>
          <th>Corre&ccedil;&atilde;o</th>
        </tr>
      </thead>
      <tbody>
      	<tr>

			{% for respostas in respostas_prova %}
				<td>{{ respostas.id }} </td>
				<td>{{ respostas.user }} </td>
				<td>{{ respostas.exam }} </td>
				<td>{{ respostas.get_status }}</td>
				<td>{{ respostas.get_progress }}</td>
				<!-- <td><a href="/respostas/{{respostas.id}}" class="btn btn-small btn-success">Vizualizar</a> </td> -->
				<td><a href="/respostas/" class="btn btn-small btn-success">Vizualizar</a> </td>
          		</tr>
			{% endfor %}

		</tbody>
	</table>
{% endif %}
  
<!-- FIM DO TRECHO DE VISUALIZACAO -->  
  
  
{% endblock content %}